
<%
    String title = "Login";
    String errorMessage ="";
            
    String username1 = request.getParameter("username");
    String password1 = request.getParameter("password");
    if (username1 != null && password1 != null) {
        if (username1.equalsIgnoreCase("administrator") && password1.equalsIgnoreCase("12345")) {
            session.setAttribute("username", username1);
            response.sendRedirect("administrator/administrator.jsp");
        } else if (username1.equalsIgnoreCase("staff") && password1.equalsIgnoreCase("54321")){
            session.setAttribute("username", username1);
            response.sendRedirect("staff/staff.jsp");
        }
        errorMessage = "Incorrect username or password, please try again";
    }
%>

<script type="text/javascript">
    
    
</script>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Supermarket Management - <%=title%></title>
    </head>
    <body>
        <div class="content">
            <h1> Please input username and password to login system</h1>
            <form name="Login" action="login.jsp" method="post">
                <div>
                    <div>
                        <div>Username :</div>
                        <input type="text" name="username" value=""  maxlength="50" />
                    </div>
                    <div>
                        <div>Password :</div>
                        <div><input type="password" name="password" value=""  maxlength="20"/></div>
                    </div>
                    <div>
                        <div><input type="submit" value="Login" name="btnLogin" onclick="return checkinput();"/>
                            <input type="submit" value="Cancel" name="btnCancel"/></div>
                    </div>
                    <div><%=errorMessage%></div>
                </div>
            </form>
        </div>
    </body>
</html>
